package com.itcc.dao;

import com.itcc.domain.VisitLog;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface VisitLogDao {

    @Select("SELECT * FROM visit_log WHERE url = #{url}")
    VisitLog findByUrl(@Param("url") String interfaceUrl);

    @Select("SELECT url from visit_log")
    String[] getAllUrl();

    @Select("SELECT * FROM visit_log")
    List<VisitLog> getAllUserLogMsg();

    @Insert("INSERT INTO visit_log(url, visit_count) VALUES(#{url}, 1)")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertLog(VisitLog log);

    @Update("UPDATE visit_log SET visit_count = visit_count + 1 WHERE url = #{url}")
    void incrementCount(@Param("url") String interfaceUrl);

}
